import Vue from 'vue'
import  Router from 'vue-router'

import DashBoard from './../views/dashboard/DashBoard'
import Login from './../views/login/Login'

const  Register = ()=> import('./../views/login/Register.vue');
const  SetPassword = ()=> import('./../views/login/SetPassword.vue');
const  ForgetPassword = ()=> import('./../views/login/ForgetPassword.vue');
const  UserChangepwd = ()=> import('./../views/login/UserChangepwd.vue');


const  Home = ()=> import('./../views/home/Home.vue');
const  NewCenter = ()=> import('./../views/home/components/news/NewCenter.vue');
const  NewsDetailPage = ()=> import('./../views/home/components/news/NewsDetailPage.vue');

const  CompanyInfoPage = ()=> import('./../views/home/components/companyInfo/CompanyInfoPage.vue');
const  IntroDetailPage = ()=> import('./../views/home/components/companyInfo/IntroDetailPage.vue');
const  IntroListPage = ()=> import('./../views/home/components/companyInfo/IntroListPage.vue');



const  Repair = ()=> import('./../views/home/components/repair/Repair.vue');
const  MasterEditRepair = ()=> import('./../views/home/components/repair/MasterEditRepair.vue');
const  RepairSuccessPage = ()=> import('./../views/home/components/repair/components/RepairSuccessPage.vue');

const  ServiceInformation = ()=> import('./../views/home/components/serviceInformation/ServiceInformation.vue');
const  ServiceInformationIndex = ()=> import('./../views/home/components/serviceInformation/ServiceInformationIndex.vue');


const  Order = ()=> import('./../views/order/Order.vue');
const  OrderDetailPage = ()=> import('../views/order/components/OrderDetail/OrderDetailPage.vue');
const  DistributionOrder = ()=> import('../views/order/components/OrderDetail/DistributionOrder.vue');
const  CancelOrderPage = ()=> import('../views/order/components/OrderDetail/CancelOrderPage.vue');
const  ResultPage = ()=> import('../views/order/components/OrderDetail/ResultPage.vue');


const  MasterOrder = ()=> import('./../views/order/MasterOrder.vue');
const  DispatchOrder = ()=> import('./../views/order/DispatchOrder.vue');



const  Mine = ()=> import('./../views/mine/Mine.vue');
const  InvoicePage = ()=> import('./../views/mine/components/invoice/InvoicePage.vue');
const  InvoiceInfoPage = ()=> import('./../views/mine/components/invoice/InvoiceInfoPage.vue');
const  SettingPage = ()=> import('./../views/mine/components/SettingPage.vue');
const  ComplaintSuggestionPage = ()=> import('./../views/mine/components/ComplaintSuggestionPage.vue');


Vue.use(Router);


export default new Router({
    // mode: 'history',
    routes:[
        {path:'/',redirect:'/dashboard'},

        {path:'/cancelOrderPage',name:'cancelOrderPage',component:CancelOrderPage,meta: {requireAuth: true }},
        {path:'/repair',name:'repair',component:Repair,meta: {requireAuth: true ,userOnly: true}},
        {path:'/masterEditRepair',name:'masterEditRepair',component:MasterEditRepair,meta: {requireAuth: true }},
        {path:'/login',name:'login',component:Login},
        {path:'/register/:type',name:'register',component:Register},
        {path:'/setPassword',name:'setPassword',component:SetPassword},
        {path:'/forgetPassword',name:'forgetPassword',component:ForgetPassword},
        {path:'/userChangepwd',name:'userChangepwd',component:UserChangepwd,meta: {requireAuth: true }},
        {path:'/intro',name:'introDetailPage',component:IntroDetailPage},
        {path:'/intros',name:'introListPage',component:IntroListPage},


        {
            path:'/dashboard',
            name:'dashboard',
            component:DashBoard,
            children:[
                {path:'/dashboard',redirect:'/dashboard/home'},
                {
                    path:'home',name:'home',component:Home,
                    children:[
                        {path:'newCenter',name:'newCenter',component:NewCenter,meta: {keepAlive: true}},
                        {path:'newsDetailPage',name:'newsDetailPage',component:NewsDetailPage},

                        {path:'repairSuccessPage',name:'repairSuccessPage',component:RepairSuccessPage,meta: {requireAuth: true }},

                        {path:'serviceInformation',name:'serviceInformation',component:ServiceInformation},
                        {path:'serviceInformationIndex',name:'serviceInformationIndex',component:ServiceInformationIndex},
                        {path:'dispatchOrder',name:'dispatchOrder',component:DispatchOrder,meta: {requireAuth: true }},
                        {path:'companyInfoPage',name:'companyInfoPage',component:CompanyInfoPage},


                    ]
                },
                {
                    path:'order',name:'order',component:Order,meta: {requireAuth: true ,keepAlive: true},
                },

                {path:'orderDetailPage',name:'orderDetailPage',component:OrderDetailPage,meta: {requireAuth: true }},
                {path:'distributionOrder',name:'distributionOrder',component:DistributionOrder,meta: {requireAuth: true }},
                {path:'resultPage',name:'resultPage',component:ResultPage},

                {path:'masterOrder',name:'masterOrder',component:MasterOrder,meta: {keepAlive: true }},
                {
                    path:'mine',name:'mine',component:Mine,meta: {requireAuth: true },
                    children:[
                        {path:'invoicePage',name:'invoicePage',component:InvoicePage,meta: {requireAuth: true ,userOnly: true}},
                        {path:'invoiceInfoPage',name:'invoiceInfoPage',component:InvoiceInfoPage},
                        {path:'settingPage',name:'settingPage',component:SettingPage,},
                        {path:'complaintSuggestionPage',name:'complaintSuggestionPage',component:ComplaintSuggestionPage,meta: {requireAuth: true ,userOnly: true}}

                    ]
                },

                // {
                //     path:'login',name:'login',component:Login,
                //     children:[
                //         {path:'register/:type',name:'register',component:Register,
                //             children:[
                //                 {path:'setPassword',name:'setPassword',component:SetPassword},
                //                 {path:'forgetPassword',name:'forgetPassword',component:ForgetPassword}
                //             ]
                //         }
                //     ]
                // },

            ]
        },

    ],
    scrollBehavior(to,from,savedPosition){
        return {x:0,y:0}
    }
});

